package homework;

import java.util.*;

public class HomeWork46 {

    public int carFleet(int target, int[] position, int[] speed) {
        int k=position.length;
        double []tmp=new double[k];
        HashMap<Integer,Integer>hashMap=new HashMap<>();
        Stack <Double>stack=new Stack();
        for (int i = 0; i < k; i++) {
            hashMap.put(position[i],speed[i]);
        }
        Arrays.sort(position);
        for (int i = k-1; i >=0 ; i--) {
            tmp[i]=(target-position[i])*1.0/hashMap.get(position[i]);
        }
        for (int i = k-1; i >= 0; i--) {
            if(stack.empty()){
                stack.add(tmp[i]);
                continue;
            }
            if(tmp[i]<=stack.peek()){
                continue;
            }else {
                stack.add(tmp[i]);
            }

        }
        return stack.size();
    }

    public static void main(String[] args) {
        HomeWork46 homeWork46=new HomeWork46();
        System.out.println(homeWork46.carFleet(10, new int[]{6,8}, new int[]{3,2}));
    }
}
